/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-11-25
 * Time: 22:23
 */

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        BigInteger sum = calculate(n);
        System.out.println("sum=" + sum + "\nbits=" + sum.bitLength());
    }

    /* 请在这里填写答案 */
    public static BigInteger calculate(int m) {
        BigInteger bigInteger = new BigInteger("1");
        for (int i = 1; i <= m; i++) {
            BigInteger temp = BigInteger.valueOf(3).pow(i);
            BigInteger term = BigInteger.valueOf((long)i).add((temp));
            bigInteger = bigInteger.multiply(term);
        }
        return bigInteger;
    }

}

